#ifndef CODEHIGHLIGHTER_H
#define CODEHIGHLIGHTER_H

#include"global.h"
#include <QRegularExpressionMatchIterator>
#include<QSyntaxHighlighter>

// 自定义语法高亮类 这个方法只设静态的设置
//动态需要使用
class CodeHighlighter : public QSyntaxHighlighter
{
public:
    CodeHighlighter(QTextDocument *parent = nullptr, const Language language = Language::Cpp);
    // virtual void SetRules();

    static QString cppKeyword;
protected:
    // 重写高亮规则
    void highlightBlock(const QString &text) override;

private:
    // 添加高亮规则
    void addHighlightingRule(const QString &pattern, const QTextCharFormat &format);

    struct HighlightingRule {
        QString pattern;
        QTextCharFormat format;
    };
    QVector<HighlightingRule> highlightingRules;


};

#endif // CODEHIGHLIGHTER_H
